package com.oig.sys.base.dao;

import com.oig.sys.base.entity.TbCustoms;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
@author wuxl
*/
public interface ITbCustomsDao extends JpaRepository<TbCustoms, Integer>, JpaSpecificationExecutor<TbCustoms> {

	TbCustoms getTbCustomsById(Integer id);

	@Query("from TbCustoms c where c.customsName=:customsName")
	TbCustoms getByCustomsName(@Param("customsName") String customsName);

	TbCustoms getByOldCode(String oldCode);

	@Query("from TbCustoms c where c.customsCode=:customsCode")
	TbCustoms getByCustomsCode(@Param("customsCode") String customsCode);

	@Query("from TbCustoms c where c.customsCode=:customsCode and c.id<>:id")
	TbCustoms getByCustomsCodeAndIdExits(@Param("customsCode") String customsCode, @Param("id")Integer id);

	@Query("from TbCustoms c where c.portCode=:portCode")
	List<TbCustoms> getByPortCode(@Param("portCode") String portCode);

}
